﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: Propietario			*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESF.General.Entity;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using ESF.SSO.Core.Entities.BasicReferences;

#endregion


namespace ESF.SSO.Core.Entities
{
	[DataContract]
	[Serializable]
	public class Enterprise : LocatedBasicReference, IEnterprise
	{
		[DataMember]
		public string IdentificationNumber { set; get; }
		
		[DataMember]
		public string IdentificationNumberDigit { set; get; }
		
		[DataMember]
		public BasicReference IdentificationType { set; get; }
		
		[DataMember]
		public List<Terminal> Terminals { set; get; }



		public string Email { set; get; }

		public string IdentificationVerificationDigit { set; get; }

		public BasicReference Type { set; get; }


		#region Constructor

		public Enterprise ()
		{
			BasicReferenceType = new BasicReferenceType () { ID = (int) BasicReferenceTypes.Enterprises };
			IsEnabled = true;
		}

		#endregion


		#region Calculados
		
        [XmlIgnore]
		public string NIT 
		{ 
			get 
			{
				if (string.IsNullOrEmpty (IdentificationNumber))
				{
					return null;
				}
			
				if (string.IsNullOrEmpty (IdentificationNumberDigit)) 
				{
					return IdentificationNumber;
				}
				
				return string.Format ("{0}-{1}", IdentificationNumber, IdentificationNumberDigit); 
			}
		}
		
		#endregion
	}
}
